#include "ICustomToolbar.h"
#include <QHBoxLayout>

ICustomToolbar::ICustomToolbar(QWidget *parent) : QWidget(parent)
{
    // 禁止父窗口颜色影响子窗口颜色
    this->setAttribute(Qt::WA_StyledBackground);
    // 设置固定高度
    this->setFixedHeight(32 + 10);
    // 设置背景颜色
    this->setStyleSheet("background-color: rgb(222, 219, 219);");

    QHBoxLayout *layout = new QHBoxLayout(this);
    layout->setContentsMargins(0, 0, 0, 0);
    layout->setSpacing(0);
    m_uploadBtn = new QPushButton(this);
    m_uploadBtn->setFixedSize(32, 32);
    m_uploadBtn->setStyleSheet("QPushButton{background-image:url(:/resource/openfile.svg);border:none;}"
                             "QPushButton:hover{"
                             "background-image:url(:/resource/openfile_hover.svg);border:none;}");
    
    m_cutBtn = new QPushButton(this);
    m_cutBtn->setFixedSize(32, 32);
    m_cutBtn->setStyleSheet("QPushButton{background-image:url(:/resource/cut.svg);border:none;}"
                             "QPushButton:hover{"
                             "background-image:url(:/resource/cut_hover.svg);border:none;}");
    // 添加间隙
    QSpacerItem *pItem1 = new QSpacerItem(20, 20, QSizePolicy::Fixed, QSizePolicy::Fixed);
    layout->addSpacerItem(pItem1);
    layout->addWidget(m_uploadBtn);
    QSpacerItem *pItem11 = new QSpacerItem(20, 20, QSizePolicy::Fixed, QSizePolicy::Fixed);
    layout->addSpacerItem(pItem11);
    layout->addWidget(m_cutBtn);
    layout->addStretch();

    setLayout(layout);

//    connect(m_uploadBtn, &QPushButton::clicked, this, [](){
//        QString selectedText = MouseSelection::getSelectedText();
//            qDebug() << "Selected text: " << selectedText;
//    });

}


// 析构
ICustomToolbar::~ICustomToolbar(){

}
